package com.wc.算法提高课.E第五章_数学知识.约数个数.反素数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/4 9:55
 * @description https://www.acwing.com/problem/content/200/
 */
public class Main {
    /**
     * 题目意思：
     * 等价于找到1 ~ N中约数个数最多的最小的数<p>
     * 思路：<p>
     * 每个数都是由质因子组成<p>
     * x = /sum_i_n pi ^ ci<p>
     * 约数个数 = /mul (1 + ci)<p>
     * 2 ^ 30 < 2 * 3 * 5 * 7 * 11 * 13 * 17 * 19* 23 * 29<p>
     * 所以最多有9个质因子<p>
     * c最大是30<p>
     * 可以用暴搜解决<p>
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
    static int n, number = 0, maxd = 0;

    public static void main(String[] args) {
        n = sc.nextInt();
        dfs(0, 30, 1, 1);
        out.println(number);
        out.flush();
    }

    /**
     * @param u    遍历下角标
     * @param last 上一个的指数
     * @param p    当前number
     * @param s    约数个数
     */
    static void dfs(int u, int last, int p, int s) {
        if (s > maxd || s == maxd && p < number) {
            maxd = s;
            number = p;
        }
        if (p > n) return;
//        if (u == 9) return;
        for (int i = 1; i <= last; i++) {
            if ((long) p * primes[u] > n) break;
            p *= primes[u];
            dfs(u + 1, i, p, s * (i + 1));
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}